{yun:}include file="$wapstyle/member/fheader.htm"{/yun}
<link rel="stylesheet" href="{yun:}$config_wapdomain{/yun}/js/mui/css/mui.picker.min.css?v={yun:}$config.cachecode{/yun}" type="text/css" />
<link rel="stylesheet" href="{yun:}$config_wapdomain{/yun}/js/mui/css/mui.poppicker.css?v={yun:}$config.cachecode{/yun}" type="text/css" />
<link rel="stylesheet" href="{yun:}$config.sy_weburl{/yun}/app/template/wap/css/style.css?v={yun:}$config.cachecode{/yun}" type="text/css" />
<link rel="stylesheet" href="{yun:}$wap_style{/yun}/js/umeditor/themes/default/css/umeditor.min.css?v={yun:}$config.cachecode{/yun}" type="text/css" />
<!--任务发布-->

<div id="app" class="mui-views">
    <div class="mui-view">
        <div class="mui-pages"></div>
    </div>
</div>
<div id="main" class="mui-page">
    <!--页面主内容区开始-->
    <div class="mui-page-content">
    	
        <div class="mui-scroll-wrapper">
            <div class="mui-scroll">
				<ul class="yun_newwap_box">
					<li class="yun_newwap_text"><span class="yun_newwap_text_name">项目名称</span>
						<span class="yun_newwap_text_box"> 
							<input type="text" id="name" name="name" value="{yun:}$rows.name{/yun}" class="reinputText" placeholder="请填写项目名称">
						</span>
					</li>
					<li class="yun_newwap_text"><span class="yun_newwap_text_name">价格预算</span>
						<span class="yun_newwap_text_box"> 
							<input type="number" id="salary" name="salary" value="{yun:}$rows.salary{/yun}" class="reinputText" placeholder="元">
						</span>
					</li>
					<li class="yun_newwap_text"><span class="yun_newwap_text_name">预计工期</span>
						<span class="yun_newwap_text_box"> 
							<input type="text" id="edate" name="edate" value="{yun:}$rows.edate{/yun}" class="reinputText" placeholder="天" onkeyup="this.value=this.value.replace(/[^0-9]/g,'')">
						</span>
					</li>
					<li>
						<span class="yun_newwap_text_name">接单截止时间</span><span class="yun_newwap_text_box">
						<button id='etimePicker' data-options='{"type":"date","value":"{yun:}if $rows.etime{/yun}{yun:}$rows.etime|date_format:"Y-m-d"{/yun}{yun:}else{/yun}2018-1-1{yun:}/if{/yun}","beginYear":{yun:}time()|date_format:"Y"{/yun},"endYear":"2500"}'  class="btn mui-btn mui-btn-block" type="button">{yun:}if $rows.etime{/yun}{yun:}$rows.etime|date_format:'%Y-%m-%d'{/yun}{yun:}else{/yun}请选择接单截止时间{yun:}/if{/yun}</button>
						<input type="hidden" id="etime" name="etime" value="{yun:}$rows.etime|date_format:'%Y-%m-%d'{/yun}">
						</span>
					</li>
					<li>
						<a href="#contenthtml"><span class="yun_newwap_text_name">项目需求</span><div class="yun_newwap_text_box yun_newwap_text_box_p" id="contentshow">{yun:}if $rows.content{/yun}{yun:}$rows.content_t{/yun}{yun:}else{/yun}请填写{yun:}/if{/yun}</div></a>
					</li><textarea style="display:none" id="contenttext">{yun:}$rows.content{/yun}</textarea>
				</ul>
				<ul class="yun_newwap_box">       
					<li class="yun_newwap_text"><span class="yun_newwap_text_name">联系人</span>
						<span class="yun_newwap_text_box"> 
							<input type="text" id="link_man" name="link_man"  value="{yun:}if $rows.link_man{/yun}{yun:}$rows.link_man{/yun}{yun:}else{/yun}{yun:}$gqinfo.name{/yun}{yun:}/if{/yun}" class="reinputText" placeholder="请填写姓名">
						</span>
					</li>
					<li class="yun_newwap_text"><span class="yun_newwap_text_name">联系电话</span>
						<span class="yun_newwap_text_box"> 
							<input type="text" id="link_moblie" name="link_moblie" 	onkeyup="this.value=this.value.replace(/[^0-9-]/g,'')" value="{yun:}if $rows.link_moblie{/yun}{yun:}$rows.link_moblie{/yun}{yun:}else{/yun}{yun:}$gqinfo.moblie{/yun}{yun:}/if{/yun}" class="reinputText" placeholder="请填写联系电话">
						</span>
					</li>
				</ul>
				<div class="yun_newwap_bth ">
         <input type="hidden" id="time" name="time" value="{yun:}$time{/yun}">
					<input id="id" name="id" value="{yun:}$rows.id{/yun}" type="hidden">
          <input type="hidden" id="state" name="state"  value="{yun:}if $rows.state{/yun}{yun:}$rows.state{/yun}{yun:}else{/yun}1{yun:}/if{/yun}">          
					<input id="pay" name="pay" value="{yun:}if $rows.pay{/yun}{yun:}$rows.pay{/yun}{yun:}else{/yun}{yun:}$pay{/yun}{yun:}/if{/yun}" type="hidden"> 
					<button id="addsubmit" type="button" class="mui-btn mui-btn-block mui-btn-primary">发布项目</button>
				</div>
            </div>
        </div>
    </div>
</div>

<!--单页面结束-->
<div id="contenthtml" class="mui-page">
    <div class="mui-page-content">
        <div class="mui-scroll-wrapper">
            <div class="mui-scroll">
                <div class="yun_wap_info_brief">
                    <div class="yun_wap_info_brief_c">
                        <div class="yun_wap_addresume_box_nexttit"> 项目需求 </div>
                        <textarea class="textAreaMsg tip contenttext" id="content" name="content" placeholder="请输入企业简介描述500字以内">{yun:}$rows.content{/yun}</textarea></div>
                    <a class="yun_wap_info_brief_tit_bc mui-action-back">确定</a>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="{yun:}$config_wapdomain{/yun}/js/mui/mui.view.js?v={yun:}$config.cachecode{/yun}" language="javascript"></script>
<script src="{yun:}$config_wapdomain{/yun}/js/mui/mui.picker.min.js?v={yun:}$config.cachecode{/yun}" language="javascript"></script>
<script src="{yun:}$config_wapdomain{/yun}/js/mui/mui.poppicker.js?v={yun:}$config.cachecode{/yun}" language="javascript"></script>
<script src="{yun:}$wap_style{/yun}/js/umeditor/umeditor.config.js?v={yun:}$config.cachecode{/yun}"></script>
<script src="{yun:}$wap_style{/yun}/js/umeditor/umeditor.min.js?v={yun:}$config.cachecode{/yun}"></script>
<script language="javascript">
var umeditor = UM.getEditor('content', {
	toolbar: false,
	elementPathEnabled: false,
	wordCount: false,
	autoHeightEnabled: false
});
var formData = new FormData();
mui.init();
var viewApi = mui('#app').view({
	defaultPage: '#main'
});
var view = viewApi.view;
(function($) {
	//初始化单页的区域滚动
	mui('.mui-scroll-wrapper').scroll({
		scrollY: true, //是否竖向滚动
		scrollX: false, //是否横向滚动
		startX: 0, //初始化时滚动至x
		startY: 0, //初始化时滚动至y
		indicators: true, //是否显示滚动条
		deceleration: 0.0006, //阻尼系数,系数越小滑动越灵敏
	    bounce: true //是否启用回弹
	});
	//处理view的后退与webview后退
	var oldBack = $.back;
	$.back = function() {
		if(viewApi.canBack()) { //如果view可以后退，则执行view的后退
			viewApi.back();
		} else { //执行webview后退
			oldBack();
		}
	};
	view.addEventListener('pageBeforeShow', function(e) { //动画开始前触发
		if(e.detail.page.id == 'contenthtml') {
			var contenttext = document.getElementById('contenttext').value;
			if(contenttext != "") {
				umeditor.setContent(contenttext);
			}
		}
	});
	view.addEventListener('pageBeforeBack', function(e) {
		if(e.detail.page.id == 'contenthtml') {
			var content = umeditor.getContent();
			if(content != "") {
				document.getElementById('contentshow').innerText = content.replace(/<\/?.+?>/g, "").replace(/ /g, "");
				document.getElementById('contenttext').innerText = content;
			}
		}
	});
})(mui);
(function($, doc) {
	$.init();
	$.ready(function() {
		var etimePicker = document.getElementById('etimePicker');
		if(etimePicker) {
			var etime = document.getElementById('etime');
			etimePicker.addEventListener('tap', function() {
				document.activeElement.blur();
				var optionsJson = this.getAttribute('data-options') || '{}';
				var options = JSON.parse(optionsJson);
				var picker = new $.DtPicker(options);
				picker.show(function(rs) {
					etime.value = rs.text;
					etimePicker.innerText = rs.text;
					picker.dispose();
				});
			}, false);
		}
	});
})(mui, document);
(function() {
	var addsubmit = document.getElementById('addsubmit');
	addsubmit.addEventListener('tap', function(event) {
		var name = $.trim($('#name').val()),
			salary = $.trim($('#salary').val()),
			edate = $.trim($('#edate').val()),
			etime = $.trim($('#etime').val()),
			content = $.trim($('#contenttext').val()),
			link_man = $.trim($('#link_man').val()),
			link_moblie = $.trim($('#link_moblie').val()),
      state = $.trim($('#state').val()),
      time = $.trim($('#time').val()),
			pay = $.trim($('#pay').val()),
			id = $.trim($('#id').val());
		if(!id || id == '') {
			id = 0;
		} else {
			id = id;
		}
		if(name == '') {
			return mui.toast('请填写项目名称！');
		}
		if(salary == '') {
			return mui.toast('请填写价格预算！');
		}
		if(edate == '') {
			return mui.toast('请填写预计工期！');
		}
		if(etime == '') {
			return mui.toast('请选择接单截止时间！');
		}else{
      if(time>etime){
        return mui.toast('接单截止时间不能小于当前时间！');
      }
    }
		if(content == '') {
			return mui.toast('请填写项目需求！');
		}
		if(link_man == '') {
			return mui.toast('请填写联系人！');
		}
		if(link_moblie == '') {
			return mui.toast('请填写联系电话！');
		}else{
            if(isjsMobile(link_moblie)==false){
                return mui.toast('联系电话格式错误！');
            }
        }
		formData.append('name', name);
		formData.append('salary', salary);
		formData.append('edate', edate);
		formData.append('etime', etime);
		formData.append('state', state);
		formData.append('content', content);
		formData.append('link_man', link_man);
		formData.append('link_moblie', link_moblie);
		formData.append('pay', pay);
		formData.append('id', id);
		formData.append('submit', 1);
		layer_load('执行中，请稍候...');
		$.ajax({
			url: wapurl +"index.php?c=free&a=addtask",
			type: 'post',
			data: formData,
			contentType: false,
			processData: false,
			dataType: 'json',
			success: function(res) {
				layer.closeAll();
				var res = JSON.stringify(res);
				var data = JSON.parse(res);
				if(data.errcode==10) {
					layermsg(data.msg, 2, function() {
						location.href = data.url;
					});
				} else if(data.errcode==9) {
					layermsg(data.msg, 2, function() {
						location.href = wapurl +"index.php?c=free&a=tasklist";
					});
				} else {
					layermsg(data.msg, 2);
					return false;
				}
			}
		})
	}, false)
})();
(function() {
    var num = '{yun:}$num{/yun}';
    if(parseInt(num) > 0 ) {
        layer.open({
            content: '您还有{yun:}$num{/yun}个订单未付款，是否继续发布！',
            btn: ['去付款', '继续发布'],
            shadeClose: false,
            yes: function() {
                setTimeout(function() {
                    location.href = "index.php?c=free&a=paylog";
                }, 0);
            }
        });
    }
})()
</script>
{yun:}include file="$wapstyle/footer.htm"{/yun}